﻿namespace EyeOpen.SilverlightDto.Ui.Sl.ViewModels
{
	using System.Collections.ObjectModel;
	using EyeOpen.SilverlightDto.Ui.Sl.CustomerServiceReference;

	public class CustomerListViewModel
	{
		public CustomerListViewModel()
		{
			CustomerList = new ObservableCollection<CustomerDto>();

			var customerServiceClient = new CustomerServiceClient();

			customerServiceClient.GetCustomerListCompleted +=
				(s, e) =>
					{
						foreach (var customerDto in e.Result)
						{
							CustomerList.Add(customerDto);
						}
					};

			customerServiceClient.GetCustomerListAsync();
		}

		public ObservableCollection<CustomerDto> CustomerList { get; private set; }
	}
}